// pages/cookies/cookies.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    renderHistoryList: {},
    activeNames: ['1']
  },

  getStorageCookies() {
    let storageList = wx.getStorageSync('Cookies'),
      // 今天0点的时间戳 
      todayTime = new Date(new Date().toLocaleDateString()).getTime(),
      // 昨天0点的时间戳
      yesterdayTime = new Date(new Date().toLocaleDateString()).getTime() - (24 * 60 * 60 * 1000)
    let renderHistoryList = this.data.renderHistoryList
    renderHistoryList['todayHistory'] = []
    renderHistoryList['yesterdayHistory'] = []
    renderHistoryList['earlierHistory'] = []
    storageList.forEach(v => {

      if (v.time > todayTime) {

        renderHistoryList['todayHistory'].push(v)

      } else if (todayTime > v.time > yesterdayTime) {

        renderHistoryList['yesterdayHistory'].push(v)

      } else {

        renderHistoryList['earlierHistory'].push(v)

      }

    })

    this.setData({
      renderHistoryList
    })

  },

  onChange(event) {
    console.log(event);
    this.setData({
      activeNames: event.detail,
    });
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.getStorageCookies()
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})